//
//  DHReturnProductCell.m
//  Dresshere
//
//  Created by ZhangPeng on 2018/1/18.
//  Copyright © 2018年 张朋. All rights reserved.
//

#import "DHReturnProductCell.h"
#import "DHCartTableViewCell.h"

@interface DHReturnProductCell()<UITableViewDelegate, UITableViewDataSource>

@property (weak, nonatomic) IBOutlet UITableView *tableView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *tableViewHeightLayour;

@property (strong, nonatomic) NSArray *sizesArray;

#warning 这儿逻辑应该有问题，一次归还衣服只能一件？
@property (strong, nonatomic) NSDictionary *productDic;

@end

@implementation DHReturnProductCell

- (NSArray *)sizesArray{
    if (!_sizesArray) {
        _sizesArray = [NSArray array];
    }
    return _sizesArray;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.tableView.scrollEnabled = NO;
    [self.tableView registerNib:[UINib nibWithNibName:@"DHCartTableViewCell" bundle:nil] forCellReuseIdentifier:kDHCartTableViewCell];
}

- (void)updateCellWithArr:(NSArray *)productArr{
    self.sizesArray = productArr;
    self.tableViewHeightLayour.constant = 100 * [self.sizesArray count];
    
    [self.tableView reloadData];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

#pragma mark - UITableViewDataSource and UITableViewDelegate
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.sizesArray.count;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 100;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    DHCartTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kDHCartTableViewCell forIndexPath:indexPath];
    NSDictionary *sizeDic = [self.sizesArray objectAtIndex:indexPath.row];
    [cell updateCellFromOrderManager:sizeDic];
    cell.selectButton.hidden = YES;
    cell.priceLabel.hidden = YES;
    return cell;
}

@end
